﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OrderManagementSystem;

namespace assignment6
{
    public partial class AddOrder : Form
    {
        public AddOrder()
        {
            InitializeComponent();
        }

        public Order order = new Order();

        private void btnAddOk_Click(object sender, EventArgs e)
        {

            order.OrderId = int.Parse(txtAddID.Text);
            order.Customer = $"{txtAddName.Text}";
            if (order.Details.Count == 0)
            {
                MessageBox.Show("请添加明细");
            }
            else
            {
                this.DialogResult = DialogResult.OK;
            }
        }

        private void btnAddDetail_Click(object sender, EventArgs e)
        {
            using (var dialog = new AddDetail())
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    order.AddDetail(dialog.detail);
                }
            }
        }

        private void txtAddName_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
